package com.aya.transaction;

import com.aya.transaction.service.BlogSimpleTransactionService;
import com.aya.transaction.service.BlogThreadTransactionService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 * 事物异常回滚
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringTransaction.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ThreadTransaction {

    @Resource
    BlogThreadTransactionService blogThreadTransactionService;

    @Test
    public void testSuccess() throws InterruptedException {
        blogThreadTransactionService.updateById("1", "transaction success");
        TimeUnit.MINUTES.sleep(10);
    }

}
